// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported ScreenshotService, ScreenshotUI, showScreenshotUI, captureScreenshot */
-const { Clutter, Cogl, Gio, GObject, GLib, Graphene, Gtk, Meta, Shell, St } = imports.gi;
+const {Clutter, Cogl, Gio, GObject, GLib, Graphene, Meta, Shell, St} = imports.gi;
const GrabHelper = imports.ui.grabHelper;
const Layout = imports.ui.layout;
yield `-${i}`;
}
+ /**
+ * Adds a record of a screenshot file in the recently used files list.
+ *
+ * @param {Gio.File} screenshotFile - The screenshot file.
+ */
+ function saveRecentFile(screenshotFile) {
+ const recentFile =
+ GLib.build_filenamev([GLib.get_user_data_dir(), 'recently-used.xbel']);
+ const uri = screenshotFile.get_uri();
+ const bookmarks = new GLib.BookmarksFile();
+ try {
+ bookmarks.load_from_file(recentFile);
+ } catch (e) {
+ if (!e.matches(GLib.BookmarkFileError.FILE_NOT_FOUND)) {
+ log(`Could not open recent file ${uri}: ${e.message}`);
+ return;
+ }
+ }
+
+ try {
+ bookmarks.add_application(uri, GLib.get_prgname(), 'gio open %u');
+ bookmarks.to_file(recentFile);
+ } catch (e) {
+ log(`Could not save recent file ${uri}: ${e.message}`);
+ }
+ }
+
const lockdownSettings =
new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' });
const disableSaveToDisk =
}
// Add it to recent files.
- Gtk.RecentManager.get_default().add_item(file.get_uri());
+ saveRecentFile(file);
}
// Create a St.ImageContent icon for the notification. We want